FatFs - f_write

## f_write

The f_write writes data to a file.

    FRESULT f_write (
      FIL* FileObject,     /* Pointer to the file object structure */
      const void* Buffer,  /* Pointer to the data to be written */
      UINT ByteToWrite,    /* Number of bytes to write */
      UINT* ByteWritten    /* Pointer to the variable to return number of bytes written */
    );

#### Parameters

FileObject
  Pointer to the open file object structure.
Buffer
  Pointer to the data to be written.
ByteToWrite
  Specifies number of bytes to write in range of UINT.
ByteWritten
  Pointer to the UINT variable to return the number of bytes written. The value is always valid after the function call regardless of the result.

#### Return Values

FR_OK, FR_DISK_ERR, FR_INT_ERR, FR_NOT_READY, FR_INVALID_OBJECT, FR_TIMEOUT

#### Description

The read/write pointer in the file object is increased in number of bytes written. After the function succeeded, `*ByteWritten` should be checked to detect the disk full. In case of `*ByteWritten < ByteToWrite`, it means the volume got full during the write operation. The function can take a time when the volume is full or close to full.

#### QuickInfo

Available when `_FS_READONLY == 0`.

#### See Also

`f_open, f_read, fputc, fputs, fprintf, f_close, FIL`

Return